<!--
@author huangHe
-->
<template>
    <div>
        <listModule
            v-show="!billDetailVisible || billDetailShowType === '1'"
            ref="listModule"
            :template-id="templateId"
            :interceptButtons="interceptButtons"
            :show-tree="true"
            :tree-config="treeConfig"
            :list-table-params-tem="listTableParamsTem"
            @buttonClick="buttonClick"
            @afterInitTemplate="afterInitTemplate"
            @afterGetList="afterGetList"
        />
        <billDetailWrap v-if="billDetailVisible" :pageUri="pageUri" />
    </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
    name: 'useapplyAudit',
    props: {},
    components: {},
    data() {
        return {
            templateId: '',
            pageUri: '',
            billId: '',
            templateBillId: '',
            treeConfig: {
                params: {
                    treeCode: 'AgencyDeptService',
                    isGetAll: true
                }
            },
            listTableParamsTem: {
                orgCode: '',
                deptCode: ''
            },
            interceptButtons: [] // 需要拦截的按钮
        };
    },
    computed: {
        ...mapState({
            billDetailVisible: state => state.commonStore.billDetailVisible, // 详情页面显示状态
            billDetailShowType: state => state.commonStore.billDetailShowType, // 详情页面打开方式
            billDetailTemplateId: state => state.commonStore.billDetailTemplateId, // 详情页面模板id
            billDetailBillId: state => state.commonStore.billDetailBillId, // 详情页面模板id
            billDetailDisabled: state => state.commonStore.billDetailDisabled, // 详情页面修改状态
            refreshListModule: state => state.commonStore.refreshListModule // 详情页面关闭后是否需要刷新列表
        })
    },
    created() {},
    methods: {
        // 按鈕点击事件，自定义按钮或者拦截按钮
        buttonClick(_this, item, rows, filterWorkflow, businessId) {},
        afterInitTemplate(template) {
            console.log(template);
        },
        afterGetList(tab, dataSource) {
            console.log(tab, dataSource);
        }
    },
    mounted() {
        this.templateId = this.$route.query.templateId;
        this.pageUri = this.$route.path;
        this.pageUri = 'useapply';
    },
    watch: {
        billDetailVisible: {
            handler(newVal) {
                if (!newVal && this.refreshListModule) {
                    this.$refs.listModule.refreshTable();
                    // 刷新表格后，还原store状态
                    this.$store.dispatch('setRefreshListModuleAction', false);
                }
            }
        }
    }
};
</script>

<style scoped></style>
